//=============================================================================
#include "CApp.h"

//=============================================================================
bool CApp::OnInit() {
    SDL_Init(SDL_INIT_EVERYTHING);

    atexit(SDL_Quit);

    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA |GLUT_DEPTH | GLUT_MULTISAMPLE);
    glutInitWindowSize(640, 480);

    OnInit_Main();

    HGLRC Window1Context = wglGetCurrentContext();

    OnInit_Preview();

    wglShareLists(wglGetCurrentContext(), Window1Context);

    glClearColor(0.0,0.0,0.0,0.0);
    gluOrtho2D(0, 640, 0, 480);
    //glutKeyboardFunc(keyCB);

    glEnable(GL_TEXTURE_2D);

    if(tempTexture.OnLoad("./gfx/test.png") == false) {
        return false;
    }

    glutMainLoop();

    return true;
}

//-----------------------------------------------------------------------------
bool CApp::OnInit_Main() {
    CApp::theApp.Win_Main = glutCreateWindow("His Light");

    glutDisplayFunc(CApp::theApp.OnRender_Main);

    return true;
}

//-----------------------------------------------------------------------------
bool CApp::OnInit_Preview() {
    Win_Preview = glutCreateWindow("Preview");

    glutDisplayFunc(CApp::OnRender_Preview);

    return true;
}

//=============================================================================


